<?php

namespace App\Http\Controllers\Api\V1\Resources;

use App\Models\BuyerNotice;
use Illuminate\Http\Resources\Json\JsonResource;

class GoldProductResource extends JsonResource
{
    public function toArray($request)
    {
    	$resource = $this->resource;

        $data = [
        	'id' => $resource->id,
	        'gold_seed_id' => $resource->gold_seed_id,
	        'gold_round_id' => $resource->gold_round_id,
	        'price_yesterday' => $resource->priceYesterday(),
	        'price_today' => $resource->priceToday(),
	        'price_tomorrow' => $resource->priceTomorrow(),
	        'round' => $resource->round,
	        'is_taken_today' => $resource->is_taken_today,
	        'is_last_round' => $resource->isLastRound(),
	        'created_at' => (string)$resource->created_at,

	        'gold_seed' => new GoldSeedResource($this->whenLoaded('goldSeed')),
        ];

        return $data;
    }
}
